package com.zjj.algorithm.learning.niuke;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @author zjj_admin
 * @date 2023/2/8 21:56
 */
public class Test20 {


    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        while (in.hasNext()){
            String s = in.nextLine();
            int a = 0, b = 0, c = 0, d = 0;
            for (int i = 0; i < s.length(); i++) {
                char c1 = s.charAt(i);
                if (c1 >= 'A' && c1 <= 'Z') {
                    a = 1;
                } else if (c1 >= 'a' && c1 <= 'z') {
                    b = 1;
                } else if (c1 >= '0' && c1 <= '9') {
                    c = 1;
                } else {
                    d = 1;
                }
            }
            if (a + b + c + d >= 3 && s.length() > 8) {
                Set<String> set = new HashSet<>();
                boolean flag = true;
                for (int i = 0; i < s.length() - 3; i++) {
                    if (set.contains(s.substring(i, i + 3))) {
                        flag = false;
                        break;
                    } else {
                        set.add(s.substring(i, i + 3));
                    }
                }
                System.out.println(flag ? "OK" : "NG");
            } else {
                System.out.println("NG");
            }
        }

    }

}
